package com.medisign.sign.log.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author ljt
 * @date 2025/4/1
 */
public class DateUtil {

    public static Date getPastDate(Date current, int past) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(current);
        calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - past);
        return calendar.getTime();
    }

    public static void main(String[] args) {
        Date pastDate = getPastDate(new Date(), 1);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(pastDate));
    }

}